/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Responses;

import Utilities.ApplicationException;
import Utilities.ExceptionMessages;
import com.sun.xml.ws.commons.virtualbox_3_2.IProgress;
import java.util.ArrayList;

/**
 * Instances of this class are used when returning a response to a virtual network
 * management request.
 *
 * @author Angel Sanadinov
 */
public class NetworkManagementResponse extends ResponseBean
{
    private IProgress operationProgress; //progress object for asynchronous operations
    private ArrayList<ApplicationException> exceptions; //operation exceptions
    
    /**
     * No-argument constructor.
     *
     * @see ResponseBean#ResponseBean()
     */
    public NetworkManagementResponse()
    {
        super();
        this.operationProgress = null;
        this.exceptions = null;
    }

    /**
     * Constructs the response object using the supplied data.
     *
     * @param requestResult the result of the request. Set to <code>true</code> for
     *                      success or to <code>false</code> for failure
     * @param exception an exception that occurred during request processing, if applicable
     */
    public NetworkManagementResponse(boolean requestResult, ApplicationException exception)
    {
        this(requestResult, exception, null);
    }

    /**
     * Constructs the response object using the supplied data.
     *
     * @param requestResult the result of the request. Set to <code>true</code> for
     *                      success or to <code>false</code> for failure
     * @param operationProgress operation progress object for asynchronous operations
     */
    public NetworkManagementResponse(boolean requestResult, IProgress operationProgress)
    {
        this(requestResult, null, operationProgress);
    }

    /**
     * Constructs the response object using the supplied data.
     *
     * @param requestResult the result of the request. Set to <code>true</code> for
     *                      success or to <code>false</code> for failure
     * @param exception an exception that occurred during request processing, if applicable
     * @param operationProgress operation progress object for asynchronous operations
     */
    public NetworkManagementResponse(boolean requestResult, ApplicationException exception, IProgress operationProgress)
    {
        super(requestResult, exception);
        this.operationProgress = operationProgress;
        this.exceptions = null;
    }

    /**
     * Constructs the response object using the supplied data.
     *
     * @param requestResult the result of the request. Set to <code>true</code> for
     *                      success or to <code>false</code> for failure
     * @param exceptions exceptions that occurred during request processing, if applicable
     */
    public NetworkManagementResponse(boolean requestResult, ArrayList<ApplicationException> exceptions)
    {
        super(requestResult, new ApplicationException(ExceptionMessages.APP_E_MULTIPLE_EXCEPTIONS));
        this.operationProgress = null;
        this.exceptions = exceptions;
    }

    /**
     * Retrieves the operation progress object.
     *
     * @return the progress object, if available or <code>null</code> otherwise
     */
    public IProgress getOperationProgress()
    {
        return operationProgress;
    }

    /**
     * Retrieves all exceptions.
     *
     * @return the list of exceptions, if available or <code>null</code> otherwise
     */
    @Override
    public ArrayList<ApplicationException> getExceptions()
    {
        return exceptions;
    }

    /**
     * Returns a textual representation of the object. <br>
     *
     * It is in the form: "ClassName: (super.toString)".
     *
     * @return the object represented as a String
     */
    @Override
    public String toString()
    {
        return NetworkManagementResponse.class.getSimpleName() + ": (" + super.toString() + ")";
    }
}
